package com.buaa.xxx0315;

import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {

    public static final int PLAY = 1;
    public static final int PAUSE = 2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }


    public void play(View view) {
        Intent intent = new Intent("myService");
        //intent.putExtra("action", PLAY);
        startService(intent);
    }

    public void pause(View view) {
        Intent intent = new Intent("music");
        intent.putExtra("action",PAUSE);
        startService(intent);
    }

    public void rmi(View view) {
        Intent intent = new Intent("rmi");
        bindService(intent, new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder proxy) {
                RmiService.MyBinder mb = (RmiService.MyBinder) proxy;
                Log.i("xxx", mb.getProgress() + ".............. ");
            }

            @Override
            public void onServiceDisconnected(ComponentName name) {

            }
        }, BIND_AUTO_CREATE);

    }
}
